/*
 * Title: WADS
 * Description: Web-based Auto flow Documents System
 * Copyright: 2007
 * Company: CoE
 * @author: Mr.Nattasan Wang-Aphisit
 * @version 1.1
 */

package wads.com;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;
import java.util.Vector;

final public class AutoDocumentTransaction implements Serializable {
//  private static final long serialVersionUID = -834898160612666911L;
  
  private String transaction_ID;
  private String template_ID;
  private String template_Name;
  private String owner_Name;
  private String reply_Email;
  private Date created_Date;
  private Properties transaction_Properties;
  private Vector<String> transaction_History;
  private int status;
  private Calendar submited_Date = null;
  private String next_PoweredUser;

  public AutoDocumentTransaction(String uniqueTID, Properties trans_Properties, String owner_Name) {
    this.created_Date = getCurrentTime();   //get Current time
    this.transaction_ID = get_uniqueTransactionID();

    this.owner_Name = owner_Name;
    this.transaction_Properties = trans_Properties;

    //set some properties for easier using
    //hidden values which are added by wad_admin_app
    this.template_ID = this.transaction_Properties.getProperty("template_ID", null);
    this.template_Name = this.transaction_Properties.getProperty("template_Name", null);

    //restricted user must provides this information during input the HTML form.
    this.reply_Email = this.transaction_Properties.getProperty("reply_Email", null);
    
    status = 1;
  }

  public Date getCurrentTime(){
    Calendar c =  Calendar.getInstance();
    return c.getTime();
  }

  public String get_uniqueTransactionID(){
    //add code here to find the unique ID for the transaction
    //this part you can discuss with A_KIJI.. he has some experience about this.
    return "000";
  }

  public void find_next_PoweredUser(){
    String next_powered_user = null;
    //add code here to find the next powered user
    this.next_PoweredUser = next_powered_user;
  }

  public boolean isNeed_to_Reply(){
    if(this.reply_Email == null)
      return false;
    return true;
  }

  public void addHistory(String history){
    this.transaction_History.add(history);
  }

  //method for get and set the properties of this object
  public String getTransaction_ID() {
    return transaction_ID;
  }
  public String getOwner_Name() {
    return owner_Name;
  }
  public String getReply_Email() {
    return reply_Email;
  }
  public Date getCreated_Date() {
    return created_Date;
  }
  public Properties getTransaction_Properties() {
    return transaction_Properties;
  }
  public String getNext_PoweredUser() {
    return next_PoweredUser;
  }
  public Vector<String> getTransaction_History() {
    return transaction_History;
  }
  public String getTemplate_ID() {
    return template_ID;
  }
  public String getTemplate_Name() {
    return template_Name;
  }
  public void setDocumentStatus(int status) {
    this.status = status;
  }
  public int getDocumentStatus() {
    return status;
  }
  public void setSubmitDate(Calendar date){
    this.submited_Date = date;
  }
  public Calendar getSubmitDate(){
    return this.submited_Date;
  }
}